package com.lpc.databindingtest2;

import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.widget.Button;
import android.widget.Toast;

/**
 * 功能:
 * <p>
 * 描述:JavaBean继承BaseObservable
 * <p>
 * Created by lipc0113 on 2018/7/25.
 */
public class User extends BaseObservable {

    private int id;
    private String name;

    public User(int id, String name) {
        this.id = id;
        this.name = name;
    }

    @Bindable
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
        notifyPropertyChanged(BR.id);
    }

    @Bindable
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
        notifyPropertyChanged(BR.name);
    }

    @BindingAdapter("show")
    public static void showName(Button btn, String s) {

        Toast.makeText(MyApplication.context, btn.getId() + s, Toast.LENGTH_SHORT).show();
    }
}
